home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 2 / BBS in a box - Trilogy II.iso / Files / Education / T-Z / XFunctions 2.2 / xFunctions 2.2 / xFunctions 2.2.rsrc / TEXT_29543_Typing Expressions.txt < prev    next >
Encoding:
Text File  |  1992-07-15  |  4.6 KB  |  15 lines

  1.      Most often, you define a function by giving an expression, or formula, for the function.  (In some ways, this gives a distorted view of functions, since only a very small fraction of all functions even have formulas!)  Since this program cannot deal with the standard mathematical notation that you are used to, you will have to learn something about how to type expressions that the computer can understand.  If you know any computer programming languages, you probably already know how to do this.  If not, there are a few simple rules that you will have to learn.
  2.  
  3.      Of course, you will often make mistakes when typing in a formula.  If what you type in is not a legal expression,  the computer will find the mistake and report it to you in an "alert box."  You should read the error message in this box, and then dismiss it by clicking on the OK button or by pressing return.  After the box disappears, the blinking insertion point will be moved to the position just after the place where the computer found the error.
  4.  
  5.       As for the rules for typing formulas:  First of all, each operation must be spelled out in detail.  Although you might want to write "2x" to indicate that x is to be multiplied by 2, the computer requires you to use an asterisk (*) if you want to do a multiplication.  Thus, you would have to write  2*x  or  x*2.  Similarly, you indicate division with  a slash (/)  and exponentiation with an up-arrow (^).  Addition and subtraction are indicated by + and - as usual.  For example, you could type  2*x^2 + 3*x - 1  to mean "two times x squared plus three times x minus 1."  Or you could enter  1/(x-1)    to mean "one divided by the quantity x minus 1."
  6.  
  7.      The second example shows the importance of using parentheses correctly.  If you had simply said "1/x-1,"  the computer would start by dividing 1 by x, and then subtract 1 from the result.  On the other hand, in 1/(x-1), the subtraction is done first and the result is then divided into 1.  The parentheses are used to indicate the order in which the operations are to be performed.  In the absence of parentheses, the rules are as follows:   Exponentiation is done first, and if there are several up-arrows, they are done from left to right, so that 2^3^x means (2^3)^x.  Next, multiplications and divisions are performed in order from left to right, so that d/2*a means (d/2)*a, not d/(2*a).  Finally, addition and subtraction are performed from left to right.  For example,  3*x^2/7-2*x  means  ((3*(x^2))/7)-(2*x).
  8.  
  9.      Besides ordinary numbers, expressions can contain the constants e (the base of the natural logarithm) and pi (which can also be entered as œÄ by holding down the option key while typing "p").   Numbers can be written in "scientific notation", that is as a number between 1 and 9.999... together with a power of 10.  The letter "e" (for exponent) is used in such numbers.  For example,  3.73e+20 means "3.73 times 10 to the power 20", and  2.1e-17 means "2.1 times 10 to the power -17".
  10.  
  11.      Besides the basic arithmetical operations, the computer will understand certain built-in functions.  The complete list is:  sin,  cos,  tan,  cot,  sec,  csc,  arctan,  arcsin,  exp,  ln,  sqrt,  cubert, abs,  and  trunc.   The first six of these are the ordinary trigonometric functions.  Arctan  and  arcsin  are inverse trig functions.   Exp  is the exponential function, e^x, and  ln  is its inverse, the natural logarithm function.   Sqrt  computes a square root and cubert does a cube root.   Abs  takes the absolute value.  Finally,  trunc  is a somewhat less standard function that takes any real number and drops its fractional part.  Thus,  trunc(x)  is always an integer.  For example,  trunc(3.7) = 3,  trunc(-4.789) = -4,  and trunc(12) = 12.   When you use any function in an expression, you must include the parentheses around its argument.  For example, you must always type "sin(x)", not "sin x", and you must type "ln(x^2+1)", not "ln x^2+1".  Also, if you want to take the square of sin(x), you must write "sin(x)^2";  This program will not recognize the notation "sin^2(x)".
  12.  
  13.      You can use functional composition in your formulas.  That is, you can use one function in the argument of another function, as in "sin(cos(x))" or "1+sqrt(1+sqrt(x))".
  14.  
  15.      This program allows you to define new functions.  Once they are defined, you can use them in expressions in the same way you use the standard functions.  You can give any name to the function.  The name does not have to consist of a single letter.  If you have a function named  fred,  you can then have formulas such as  "fred(x)",  "2+3*fred(x^2)", or "sin(fred(x)+1) - fred(fred(x))".